<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 提现操作</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link href="/front/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/front/hAdmin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/front/hAdmin/css/animate.css" rel="stylesheet">
    <link href="/front/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">
    <style>
    .btn{
        margin-right: 10px;
        margin-top: 5px;
    }
    </style>
</head>

<body class="gray-bg">


<div class="wrapper wrapper-content">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>申请提现</h5>
                </div>
                <div class="ibox-content">
                    @if($bank_card_no != null)
                        <label>银行卡号:</label>
                        <div class="form-group">
                            <input type="text" class="form-control bank_card_no" disabled value="{{$bank_card_no}}">
                        </div>
                        <label>总收益:</label>
                        <div class="form-group">
                            <input type="text" class="form-control" disabled value="{{$userinfo->total_revenue}}">
                        </div>
                        <label>可提金额:</label>
                        <div class="form-group">
                            <input type="text" class="form-control balance" disabled value="{{$userinfo->balance}}">
                        </div>
                        <label>申请提现金额:</label>
                        <div class="form-group">
                            <input type="text" class="form-control" id="withdraw">
                        </div>
                        <div class="btn-list">
                            <button type="button" class="btn btnbtn-w-m btn-primary submit">&nbsp;&nbsp;<i class="fa fa-check"></i>&nbsp;&nbsp;提交申请</button>
                            <button type="button" class="btn btn-w-m btn-info return"><i class="fa fa-reply"></i>&nbsp;&nbsp;返回列表</button>
                        </div>
                    @else
                        <button type="button" class="btn btn-w-m btn-info return"><i class="fa fa-reply"></i>&nbsp;&nbsp;返回列表</button>
                    @endif
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/front/hAdmin/js/jquery.min.js?v=2.1.4"></script>
<script src="/front/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="/front/hAdmin/js/content.js?v=1.0.0"></script>


<script src="/front/hAdmin/js/plugins/jeditable/jquery.jeditable.js"></script>
<!-- Data Tables -->
<script src="/front/hAdmin/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/front/hAdmin/js/plugins/dataTables/dataTables.bootstrap.js"></script>

<script src="/front/hAdmin/js/plugins/layer/layer.min.js"></script>

</body>
<script type="text/javascript">

    @if($bank_card_no == null)
        layer.msg('查无银行卡信息或未通过审核,请审核通过后再试!', {
        time: 8000
    });
    @endif
    $(".submit").click(function () {
        var withdraw = $("#withdraw").val();
        var balance = $(".balance").val();
        var bank_card_no = $(".bank_card_no").val();
        if (withdraw == '') {
            layer.tips('请输入要申请提现的金额', '#withdraw', {
                tips: [1, '#FF0509'],
                time: 3000
            });
            $("#withdraw").focus();
            return false;
        }
        if (isNaN(withdraw)) {
            layer.tips('请输入数字', '#withdraw', {
                tips: [1, '#FF0509'],
                time: 3000
            });
            $("#withdraw").focus();
            return false;
        }
        if (balance < withdraw) {
            layer.tips('申请金额不能大于可提金额', '#withdraw', {
                tips: [1, '#FF0509'],
                time: 3000
            });
            $("#withdraw").focus();
            return false;
        }
        layer.msg('提交申请中...');
        $(".submit").attr("disabled", "disabled");
        $.ajax({
            type: "post",
            url: "/api/statistics/apply-withdraw",
            data: {
                "user_id": {{Session::get('user_id')}},
                "user_card_id": '{{$user_card_id}}',
                "total_fee": withdraw,
                "_token": '{{csrf_token()}}'
            },
            success: function (msg) {
                if (msg.state == "M00000") {
                    layer.msg('提交成功!', {
                        time: 2000
                    });
                    $(".submit").removeAttr("disabled");
                    $(".balance").val(balance-withdraw);
                } else {
                    layer.msg(msg.message);
                    $(".submit").removeAttr("disabled");
                }
            },
            error: function () {
                layer.msg("网络异常,请重试~");
                $(".submit").removeAttr("disabled");
            }
        });
    });
    $(".return").click(function () {
        window.location.href = "/authentication/withdraw-deposit";
    });
</script>
</html>
